package pam.web;

import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import pam.core.IFile;

class Parameters implements Serializable {

	private static final long serialVersionUID = 9111477577193620724L;
	private Map map;

	public Parameters(Map map) {
		this.map = map;
	}

	public Parameters() {
		map = new ConcurrentHashMap();
	}

	public String getString(String key) {
		String[] tmp = getStringArray(key);
		if (tmp == null)
			return null;

		if (tmp.length >= 1) {
			return tmp[0];
		}

		return null;
	}

	public String[] getStringArray(String key) {
		String[] value = (String[]) map.get(key);
		return value;
	}

	public pam.core.IFile getFile(String key) {
		Object o = this.map.get(key);
		return (pam.core.IFile) o;
	}

	public byte[] getBytes(String key) {
		IFile objFile = getFile(key);
		return objFile != null ? objFile.getContent() : null;
	}

}
